{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# hvPlot.area"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "```{eval-rst}\n",
    ".. currentmodule:: hvplot\n",
    "\n",
    ".. automethod:: hvPlot.area\n",
    "```\n",
    "\n",
    "## Backend-specific styling options\n",
    "\n",
    "```{eval-rst}\n",
    ".. backend-styling-options:: area\n",
    "```\n",
    "\n",
    "## Examples \n",
    "\n",
    "### Simple area plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas  # noqa\n",
    "import pandas as pd\n",
    "\n",
    "df = pd.DataFrame({\"x\": [0, 1, 2, 3], \"y\": [0, 1, 4, 9]})\n",
    "\n",
    "df.hvplot.area(x=\"x\", y=\"y\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Single area for a timeseries\n",
    "\n",
    "This example displays the area under Apple’s stock adjusted closing price over time."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas # noqa\n",
    "\n",
    "df = hvplot.sampledata.apple_stocks(\"pandas\")\n",
    "\n",
    "df.hvplot.area(x=\"date\", y=\"adj_close\", color=\"#1e85f7\", alpha=0.5, height=300)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Stacked area for multiple series\n",
    "\n",
    "This example shows stacked areas for several tech company stock prices. `stack` is `True` by default."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas # noqa\n",
    "\n",
    "df = hvplot.sampledata.stocks(\"pandas\")\n",
    "\n",
    "df.hvplot.area(x=\"date\", y=[\"Apple\", \"Amazon\", \"Netflix\"], alpha=0.4, ylim=(1, None))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Non-stacked area for multiple series"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This example shows non-stacked areas for several tech company stock prices, by setting `stacked` to `False`. Note that `alpha` is automatically set to `0.5` in this case."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas # noqa\n",
    "\n",
    "df = hvplot.sampledata.stocks(\"pandas\")\n",
    "\n",
    "df.hvplot.area(x=\"date\", y=[\"Apple\", \"Amazon\", \"Netflix\"], ylim=(1, None), stacked=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Area between two lines using y and y2\n",
    "\n",
    "This example fills the space between the low and high prices of Apple's stock, by setting `y` (low) and `y2` (high)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas # noqa\n",
    "import pandas as pd\n",
    "\n",
    "df = hvplot.sampledata.apple_stocks(\"pandas\")\n",
    "\n",
    "df.hvplot.area(\n",
    "    x=\"date\",\n",
    "    y=\"low\",\n",
    "    y2=\"high\",\n",
    "    ylabel=\"Prices\",\n",
    "    xlim=(pd.Timestamp(\"2023-03-01\"), pd.Timestamp(\"2023-11-01\")),\n",
    "    ylim=(140, 200),\n",
    ")"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
